<%@page import="com.wanmait.movies.vo.Concerned"%>
<%@page import="java.util.ArrayList"%>
<%@page import="com.wanmait.movies.vo.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<%
String path=request.getContextPath();
%>
<style type="text/css">
#show{
width:800px;
height:550px;
margin: auto;
border:1px solid black;
}
.movies{
width:798px;
height:100px;
border:1px solid black;
margin: auto;
}
#fenye{
height:30px;
width:300px;
margin: auto;
text-align: center;
}
#ThisPage{
width:30px;

}
.ingotmation{
width:98px;
height:98px;
line-height: 100px;
text-align: center;
float: left;
}
.ingotmations{
width:98px;
height:73px;
text-align: center;
float: left;
padding-top: 25px;
}
img{
width:60px;
height:60px;
}
img:hover{
width:70px;
height: 70px;
}
a:link,a:visited{ 
 text-decoration:none;  /*超链接无下划线*/ 
} 
#checkedsize{
padding-left: 40px;
width: 300px;
height:20px; 
}
</style>
<script type="text/javascript" src="<%=path %>/js/jquery-3.5.1.min.js"></script>
<script type="text/javascript">
$(function () {
	$("#ThisPage").blur(function(){//给分页中间的text加上失焦的方法，失焦后去指定页数
		var thispage=$("#ThisPage").val();
		var pagemax=$("#NextPage").attr("pagemax");
		if(thispage>pagemax){
			thispage=pagemax;
			$("#ThisPage").val(pagemax);
		}else{
			location.href="<%=path%>/UserServlet?action=concerned&thispage="+thispage;
		}
		
	});
});
$(function () {//上一页
	$("#LastPage").click(function(){
		//alert("11654");
		var thispage=$("#ThisPage").val();
		thispage--;
		if(thispage<1){
			thispage=1;
		}else{
			location.href="<%=path%>/UserServlet?action=concerned&thispage="+thispage;
		}
	});
});
$(function () {//下一页
	$("#NextPage").click(function(){
		var thispage=$("#ThisPage").val();
		var pagemax=$("#NextPage").attr("pagemax");
		      thispage++;
		    //  alert(pagemax);
		if(thispage>pagemax){
			thispage=pagemax;
		}else{
			location.href="<%=path%>/UserServlet?action=concerned&thispage="+thispage;
		}
		});
});
</script>
<script type="text/javascript">//关于取关的一些功能
$(function () {//每个人后面的取关
	$("#show").on("click",".Elimination",function () {
		var concernedid=$(this).attr("gid");
		alert(concernedid);
		var temp = $(this);
		$.ajax({
         url:"<%=path%>/UserServlet",
         type:"get",
         data:{action:"concerneddelete",concernedid:concernedid},
         success:function (mes){
        	 temp.parent().parent().remove();
        		
         }
		});
	});
	
});
$(function () {//全选框 点中全选
	$("#show").on("click","#allconcerned",function(){
		var flag=$("#allconcerned").prop("checked");
		if(flag==true){
			$(".concerneds").prop("checked",true);
		}else{
			$(".concerneds").prop("checked",false);
		}
		 
	});
});
$(function () {
	$("#alldelete").click(function(){//批量取关
	//	alert("21131");
		var cks= $(".concerneds:checked");
		var str="";
		
		cks.each(function(){
			var gid=$(this).attr("gid");
			str=str+","+gid;
			$(this).parent().parent().remove()
		});
		str=str.substring(1);
		if(str!=""){
			//alert(str);
			$.ajax({
		         url:"<%=path%>/UserServlet",
		         type:"get",
		         data:{action:"concerneddelete",concernedid:str},
		         success:function (mes){
		        	 $("#allconcerned").prop("checked",false);
		         }
				});
			} else{
			$(".Tips").html("请勾选关注");
		}
	});
})





</script>
<style type="text/css">
img{
border-radius:60px; 
}
</style>
</head>

<!-- 这个地方是点击我的关注之后进来的网页，里面关注的人的头像  昵称 点击进入他的主页 -->
<div id="show">
<div id="checkedsize"><input type="checkbox" id="allconcerned" /><a href="javascript:" id="alldelete">批量取关</a><span class="Tips"></span></div>
<%
ArrayList<Concerned> allconcerned=(ArrayList<Concerned>)request.getAttribute("allconcerned");
for(Concerned concerned:allconcerned){
%>
<div  class="movies">
<div  class="ingotmations"><input type="checkbox" class="concerneds" gid="<%=concerned.getId()%>"/></div>
<div  class="ingotmations" ><a href="javascript:"><img src="<%=path %>/images/<%=concerned.getReuserId().getUserFaceimage() %>"/></a></div><!-- 关注人的头像 -->
<div  class="ingotmation" ><a href="javascript:"><%=concerned.getReuserId().getUserName() %></a></div><!-- 关注的用户名 -->
<div  class="ingotmation"><a href="javascript:">TA的主页</a></div>
<div  class="ingotmation"><a href="javascript:" class="Elimination" gid="<%=concerned.getId()%>">取消关注</a></div>
</div>
<%
}
%>
</div>
<div id="fenye">
<a href="javascript:" id="LastPage">上一页</a>
<input type="text" id="ThisPage" value="<%=(int)request.getAttribute("ThisPage")%>" />
<a href="javascript:" id="NextPage" pagemax="<%=request.getAttribute("pagemax")%>">下一页</a>
</div>
</body>
</html>